#include <QApplication>
#include "ElaApplication.h"
#include "ElaTheme.h"
#include "ElaWidget.h"
#include "ElaPushButton.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGroupBox>
#include <QLabel>
#include <QTimer>
#include <QCheckBox>
#include <QDebug>

class ElaPushButtonDemo : public ElaWidget
{
    Q_OBJECT

  public:
    ElaPushButtonDemo(QWidget *parent = nullptr) : ElaWidget(parent)
    {
        setWindowTitle("ElaPushButton 功能演示");
        resize(600, 700);
        setWindowButtonFlags(ElaAppBarType::StayTopButtonHint | ElaAppBarType::MinimizeButtonHint | ElaAppBarType::MaximizeButtonHint | ElaAppBarType::CloseButtonHint | ElaAppBarType::ThemeChangeButtonHint | ElaAppBarType::NavigationButtonHint);

        setupUI();
        setupConnections();
    }

  private:
    void setupUI()
    {
        QVBoxLayout *mainLayout = new QVBoxLayout(this);

        // 1. 基础按钮展示
        mainLayout->addWidget(createBasicButtonGroup());

        // 2. 圆角按钮展示
        mainLayout->addWidget(createBorderRadiusGroup());

        // 3. 自定义颜色按钮展示
        mainLayout->addWidget(createCustomColorGroup());

        // 4. 状态按钮展示
        mainLayout->addWidget(createStateButtonGroup());

        // 5. 高级功能展示
        mainLayout->addWidget(createAdvancedFeatureGroup());

        // 6. 主题测试区域
        mainLayout->addWidget(createThemeTestGroup());

        // 7. 动态修改演示
        mainLayout->addWidget(createDynamicModifyGroup());

        // 8. 切换按钮展示 - 新增
        mainLayout->addWidget(createToggleButtonGroup());

        mainLayout->addStretch();
    }

    // 创建基础按钮组 - 展示最基本的按钮功能
    QGroupBox *createBasicButtonGroup()
    {
        QGroupBox *group = new QGroupBox("基础按钮", this);
        QVBoxLayout *layout = new QVBoxLayout(group);

        // 基础按钮1: 默认样式
        ElaPushButton *btn1 = new ElaPushButton("默认按钮", this);

        // 基础按钮2: 带长文字的按钮
        ElaPushButton *btn2 = new ElaPushButton("这是一个带较长文字的按钮", this);

        // 基础按钮3: 不同宽度的按钮
        ElaPushButton *btn3 = new ElaPushButton("不同宽度的按钮", this);
        btn3->setMinimumWidth(200);

        // 基础按钮4: 不同高度的按钮
        ElaPushButton *btn4 = new ElaPushButton("不同高度的按钮", this);
        btn4->setFixedHeight(50);

        layout->addWidget(btn1);
        layout->addWidget(btn2);
        layout->addWidget(btn3);
        layout->addWidget(btn4);

        // 存储按钮用于后续操作
        m_basicButtons << btn1 << btn2 << btn3 << btn4;

        return group;
    }

    // 创建圆角按钮组 - 展示不同圆角大小的效果
    QGroupBox *createBorderRadiusGroup()
    {
        QGroupBox *group = new QGroupBox("圆角按钮", this);
        QHBoxLayout *layout = new QHBoxLayout(group);

        // 直角按钮
        ElaPushButton *btn0 = new ElaPushButton("直角 (0)", this);
        btn0->setBorderRadius(0);

        // 小圆角按钮
        ElaPushButton *btn2 = new ElaPushButton("小圆角 (2)", this);
        btn2->setBorderRadius(2);

        // 默认圆角按钮
        ElaPushButton *btn5 = new ElaPushButton("默认圆角 (5)", this);
        btn5->setBorderRadius(5);

        // 大圆角按钮
        ElaPushButton *btn10 = new ElaPushButton("大圆角 (10)", this);
        btn10->setBorderRadius(10);

        // 超大圆角按钮 (接近圆形)
        ElaPushButton *btn20 = new ElaPushButton("超大圆角 (20)", this);
        btn20->setBorderRadius(20);

        layout->addWidget(btn0);
        layout->addWidget(btn2);
        layout->addWidget(btn5);
        layout->addWidget(btn10);
        layout->addWidget(btn20);

        return group;
    }

    // 创建自定义颜色按钮组 - 展示颜色定制功能
    QGroupBox *createCustomColorGroup()
    {
        QGroupBox *group = new QGroupBox("自定义颜色按钮", this);
        QVBoxLayout *layout = new QVBoxLayout(group);

        // 蓝色主题按钮 - 完整的颜色状态设置
        ElaPushButton *blueBtn = new ElaPushButton("蓝色主题按钮", this);
        blueBtn->setLightDefaultColor(QColor("#2196F3"));  // 浅色主题默认状态颜色
        blueBtn->setDarkDefaultColor(QColor("#1976D2"));   // 深色主题默认状态颜色
        blueBtn->setLightHoverColor(QColor("#42A5F5"));    // 浅色主题悬停状态颜色
        blueBtn->setDarkHoverColor(QColor("#1565C0"));     // 深色主题悬停状态颜色
        blueBtn->setLightPressColor(QColor("#0D47A1"));    // 浅色主题按下状态颜色
        blueBtn->setDarkPressColor(QColor("#0D47A1"));     // 深色主题按下状态颜色
        blueBtn->setLightTextColor(Qt::black);             // 浅色主题文字颜色
        blueBtn->setDarkTextColor(Qt::white);              // 深色主题文字颜色

        // 绿色主题按钮
        ElaPushButton *greenBtn = new ElaPushButton("绿色主题按钮", this);
        greenBtn->setLightDefaultColor(QColor("#4CAF50"));
        greenBtn->setDarkDefaultColor(QColor("#388E3C"));
        greenBtn->setLightHoverColor(QColor("#66BB6A"));
        greenBtn->setDarkHoverColor(QColor("#2E7D32"));
        greenBtn->setLightPressColor(QColor("#1B5E20"));
        greenBtn->setDarkPressColor(QColor("#1B5E20"));
        greenBtn->setLightTextColor(Qt::black);
        greenBtn->setDarkTextColor(Qt::white);

        // 橙色主题按钮
        ElaPushButton *orangeBtn = new ElaPushButton("橙色主题按钮", this);
        orangeBtn->setLightDefaultColor(QColor("#FF9800"));
        orangeBtn->setDarkDefaultColor(QColor("#F57C00"));
        orangeBtn->setLightHoverColor(QColor("#FFB74D"));
        orangeBtn->setDarkHoverColor(QColor("#FF9800"));
        orangeBtn->setLightPressColor(QColor("#E65100"));
        orangeBtn->setDarkPressColor(QColor("#E65100"));
        orangeBtn->setLightTextColor(Qt::black);
        orangeBtn->setDarkTextColor(Qt::white);

        // 紫色主题按钮 - 展示不同的文字颜色
        ElaPushButton *purpleBtn = new ElaPushButton("紫色主题按钮", this);
        purpleBtn->setLightDefaultColor(QColor("#9C27B0"));
        purpleBtn->setDarkDefaultColor(QColor("#7B1FA2"));
        purpleBtn->setLightHoverColor(QColor("#BA68C8"));
        purpleBtn->setDarkHoverColor(QColor("#9C27B0"));
        purpleBtn->setLightPressColor(QColor("#6A1B9A"));
        purpleBtn->setDarkPressColor(QColor("#4A148C"));
        purpleBtn->setLightTextColor(QColor("#E1BEE7"));  // 浅紫色文字
        purpleBtn->setDarkTextColor(QColor("#F3E5F5"));   // 更浅的紫色文字

        layout->addWidget(blueBtn);
        layout->addWidget(greenBtn);
        layout->addWidget(orangeBtn);
        layout->addWidget(purpleBtn);

        return group;
    }

    // 创建状态按钮组 - 展示不同状态的按钮
    QGroupBox *createStateButtonGroup()
    {
        QGroupBox *group = new QGroupBox("按钮状态", this);
        QHBoxLayout *layout = new QHBoxLayout(group);

        // 正常状态按钮
        ElaPushButton *normalBtn = new ElaPushButton("正常按钮", this);

        // 系统默认禁用状态按钮
        ElaPushButton *disabledBtn = new ElaPushButton("禁用按钮", this);
        disabledBtn->setEnabled(false);

        // 自定义颜色的禁用状态按钮
        ElaPushButton *customDisabledBtn = new ElaPushButton("自定义禁用", this);
        customDisabledBtn->setEnabled(false);
        customDisabledBtn->setLightDefaultColor(QColor("#BDBDBD"));  // 浅灰色
        customDisabledBtn->setDarkDefaultColor(QColor("#616161"));   // 深灰色

        layout->addWidget(normalBtn);
        layout->addWidget(disabledBtn);
        layout->addWidget(customDisabledBtn);

        return group;
    }

    // 创建高级功能组 - 展示更多高级功能
    QGroupBox *createAdvancedFeatureGroup()
    {
        QGroupBox *group = new QGroupBox("高级功能", this);
        QVBoxLayout *layout = new QVBoxLayout(group);

        // 鼠标跟踪演示
        QLabel *trackingLabel = new QLabel("鼠标悬停和按下状态颜色演示:", this);

        // 悬停效果明显的按钮
        ElaPushButton *hoverBtn = new ElaPushButton("强烈悬停效果", this);
        hoverBtn->setLightDefaultColor(QColor("#E3F2FD"));  // 非常浅的蓝色
        hoverBtn->setLightHoverColor(QColor("#2196F3"));    // 深蓝色悬停
        hoverBtn->setLightPressColor(QColor("#1976D2"));    // 更深的蓝色按下
        hoverBtn->setLightTextColor(QColor("#1976D2"));     // 默认文字颜色
        hoverBtn->setDarkTextColor(Qt::white);              // 悬停时文字变白

        // 渐变颜色按钮
        ElaPushButton *gradientBtn = new ElaPushButton("渐变颜色效果", this);
        gradientBtn->setLightDefaultColor(QColor("#FF6B6B"));  // 珊瑚红
        gradientBtn->setLightHoverColor(QColor("#FF8E8E"));    // 浅珊瑚红
        gradientBtn->setLightPressColor(QColor("#FF5252"));    // 深珊瑚红
        gradientBtn->setLightTextColor(Qt::white);

        // 边框强调按钮
        ElaPushButton *borderBtn = new ElaPushButton("边框强调按钮", this);
        borderBtn->setLightDefaultColor(Qt::transparent);  // 透明背景
        borderBtn->setLightHoverColor(QColor("#E3F2FD"));  // 悬停时有背景
        borderBtn->setLightPressColor(QColor("#BBDEFB"));  // 按下时背景更深
        borderBtn->setLightTextColor(QColor("#1976D2"));   // 蓝色文字

        layout->addWidget(trackingLabel);
        layout->addWidget(hoverBtn);
        layout->addWidget(gradientBtn);
        layout->addWidget(borderBtn);

        return group;
    }

    // 创建主题测试组 - 测试主题切换功能
    QGroupBox *createThemeTestGroup()
    {
        QGroupBox *group = new QGroupBox("主题测试", this);
        QVBoxLayout *layout = new QVBoxLayout(group);

        QLabel *infoLabel = new QLabel("点击下方按钮切换明暗主题，观察所有按钮的颜色变化", this);

        // 主题切换按钮
        ElaPushButton *themeToggleBtn = new ElaPushButton("切换主题", this);
        themeToggleBtn->setLightDefaultColor(QColor("#9C27B0"));
        themeToggleBtn->setDarkDefaultColor(QColor("#7B1FA2"));
        themeToggleBtn->setLightHoverColor(QColor("#BA68C8"));
        themeToggleBtn->setDarkHoverColor(QColor("#9C27B0"));
        themeToggleBtn->setLightPressColor(QColor("#6A1B9A"));
        themeToggleBtn->setDarkPressColor(QColor("#4A148C"));
        themeToggleBtn->setLightTextColor(Qt::white);
        themeToggleBtn->setDarkTextColor(Qt::white);

        // 显示当前主题状态
        m_themeStatusLabel = new QLabel(this);
        updateThemeStatusLabel();

        layout->addWidget(infoLabel);
        layout->addWidget(m_themeStatusLabel);
        layout->addWidget(themeToggleBtn);

        m_themeToggleBtn = themeToggleBtn;

        return group;
    }

    // 创建动态修改组 - 展示运行时修改属性
    QGroupBox *createDynamicModifyGroup()
    {
        QGroupBox *group = new QGroupBox("动态修改演示", this);
        QVBoxLayout *layout = new QVBoxLayout(group);

        // 被修改的目标按钮
        ElaPushButton *dynamicBtn = new ElaPushButton("点击我改变属性", this);

        // 修改按钮 - 点击后修改上面按钮的属性
        ElaPushButton *modifyBtn = new ElaPushButton("修改上方按钮属性", this);
        modifyBtn->setLightDefaultColor(QColor("#607D8B"));
        modifyBtn->setDarkDefaultColor(QColor("#455A64"));

        // 启用/禁用切换复选框
        QCheckBox *enableCheckBox = new QCheckBox("启用/禁用上方按钮", this);
        enableCheckBox->setChecked(true);

        layout->addWidget(dynamicBtn);
        layout->addWidget(modifyBtn);
        layout->addWidget(enableCheckBox);

        m_dynamicButton = dynamicBtn;
        m_modifyButton = modifyBtn;
        m_enableCheckBox = enableCheckBox;

        return group;
    }

    // 创建切换按钮组 - 展示按下保持/释放的切换按钮
    QGroupBox *createToggleButtonGroup()
    {
        QGroupBox *group = new QGroupBox("切换按钮 (Toggle Buttons)", this);
        QVBoxLayout *layout = new QVBoxLayout(group);

        QLabel *infoLabel = new QLabel("点击按钮会保持按下状态，再次点击才会释放。每个按钮有不同的按下和弹起样式。", this);
        layout->addWidget(infoLabel);

        // 样式1: 蓝色切换按钮
        QHBoxLayout *row1 = new QHBoxLayout();
        ElaPushButton *blueToggleBtn = new ElaPushButton("蓝色切换 - 未按下", this);
        blueToggleBtn->setLightDefaultColor(QColor("#E3F2FD"));  // 弹起状态：浅蓝色
        blueToggleBtn->setLightHoverColor(QColor("#BBDEFB"));
        blueToggleBtn->setLightPressColor(QColor("#2196F3"));  // 按下状态：深蓝色
        blueToggleBtn->setLightTextColor(QColor("#1976D2"));   // 弹起状态文字颜色
        blueToggleBtn->setProperty("toggleState", false);      // 自定义属性记录状态
        blueToggleBtn->setProperty("normalText", "蓝色切换 - 未按下");
        blueToggleBtn->setProperty("pressedText", "蓝色切换 - 已按下");

        row1->addWidget(blueToggleBtn);
        row1->addStretch();

        // 样式2: 绿色切换按钮
        QHBoxLayout *row2 = new QHBoxLayout();
        ElaPushButton *greenToggleBtn = new ElaPushButton("绿色切换 - 未按下", this);
        greenToggleBtn->setLightDefaultColor(QColor("#E8F5E8"));  // 弹起状态：浅绿色
        greenToggleBtn->setLightHoverColor(QColor("#C8E6C9"));
        greenToggleBtn->setLightPressColor(QColor("#4CAF50"));  // 按下状态：深绿色
        greenToggleBtn->setLightTextColor(QColor("#388E3C"));   // 弹起状态文字颜色
        greenToggleBtn->setProperty("toggleState", false);
        greenToggleBtn->setProperty("normalText", "绿色切换 - 未按下");
        greenToggleBtn->setProperty("pressedText", "绿色切换 - 已按下");

        row2->addWidget(greenToggleBtn);
        row2->addStretch();

        // 样式3: 红色切换按钮
        QHBoxLayout *row3 = new QHBoxLayout();
        ElaPushButton *redToggleBtn = new ElaPushButton("红色切换 - 未按下", this);
        redToggleBtn->setLightDefaultColor(QColor("#FFEBEE"));  // 弹起状态：浅红色
        redToggleBtn->setLightHoverColor(QColor("#FFCDD2"));
        redToggleBtn->setLightPressColor(QColor("#F44336"));  // 按下状态：深红色
        redToggleBtn->setLightTextColor(QColor("#D32F2F"));   // 弹起状态文字颜色
        redToggleBtn->setProperty("toggleState", false);
        redToggleBtn->setProperty("normalText", "红色切换 - 未按下");
        redToggleBtn->setProperty("pressedText", "红色切换 - 已按下");

        row3->addWidget(redToggleBtn);
        row3->addStretch();

        // 样式4: 橙色切换按钮 - 带边框效果
        QHBoxLayout *row4 = new QHBoxLayout();
        ElaPushButton *orangeToggleBtn = new ElaPushButton("橙色切换 - 未按下", this);
        orangeToggleBtn->setLightDefaultColor(Qt::transparent);  // 弹起状态：透明
        orangeToggleBtn->setLightHoverColor(QColor("#FFF3E0"));
        orangeToggleBtn->setLightPressColor(QColor("#FF9800"));  // 按下状态：橙色
        orangeToggleBtn->setLightTextColor(QColor("#F57C00"));   // 弹起状态文字颜色
        orangeToggleBtn->setProperty("toggleState", false);
        orangeToggleBtn->setProperty("normalText", "橙色切换 - 未按下");
        orangeToggleBtn->setProperty("pressedText", "橙色切换 - 已按下");

        row4->addWidget(orangeToggleBtn);
        row4->addStretch();

        // 样式5: 紫色切换按钮 - 圆角更大
        QHBoxLayout *row5 = new QHBoxLayout();
        ElaPushButton *purpleToggleBtn = new ElaPushButton("紫色切换 - 未按下", this);
        purpleToggleBtn->setBorderRadius(15);                      // 更大的圆角
        purpleToggleBtn->setLightDefaultColor(QColor("#F3E5F5"));  // 弹起状态：浅紫色
        purpleToggleBtn->setLightHoverColor(QColor("#E1BEE7"));
        purpleToggleBtn->setLightPressColor(QColor("#9C27B0"));  // 按下状态：深紫色
        purpleToggleBtn->setLightTextColor(QColor("#7B1FA2"));   // 弹起状态文字颜色
        purpleToggleBtn->setProperty("toggleState", false);
        purpleToggleBtn->setProperty("normalText", "紫色切换 - 未按下");
        purpleToggleBtn->setProperty("pressedText", "紫色切换 - 已按下");

        row5->addWidget(purpleToggleBtn);
        row5->addStretch();

        layout->addLayout(row1);
        layout->addLayout(row2);
        layout->addLayout(row3);
        layout->addLayout(row4);
        layout->addLayout(row5);

        // 存储切换按钮用于信号连接
        m_toggleButtons << blueToggleBtn << greenToggleBtn << redToggleBtn << orangeToggleBtn << purpleToggleBtn;

        return group;
    }

    // 更新主题状态标签
    void updateThemeStatusLabel()
    {
        if (m_themeStatusLabel)
        {
            auto currentMode = eTheme->getThemeMode();
            QString modeName = (currentMode == ElaThemeType::Light) ? "浅色主题" : "深色主题";
            QString color = (currentMode == ElaThemeType::Light) ? "blue" : "gray";
            m_themeStatusLabel->setText(QString("当前主题: <font color='%1'><b>%2</b></font>").arg(color).arg(modeName));
        }
    }

    void setupConnections()
    {
        // 主题切换连接
        connect(m_themeToggleBtn, &ElaPushButton::clicked, this, [this]() {
            auto currentMode = eTheme->getThemeMode();
            auto newMode = (currentMode == ElaThemeType::Light) ? ElaThemeType::Dark : ElaThemeType::Light;
            eTheme->setThemeMode(newMode);

            // 更新主题状态显示
            updateThemeStatusLabel();

            QString modeName = (newMode == ElaThemeType::Light) ? "浅色" : "深色";
            m_themeToggleBtn->setText(QString("当前主题: %1 - 点击切换").arg(modeName));
        });

        // 监听主题变化来更新标签
        connect(eTheme, &ElaTheme::themeModeChanged, this, [this]() { updateThemeStatusLabel(); });

        // 动态修改演示连接
        static int clickCount = 0;
        connect(m_modifyButton, &ElaPushButton::clicked, this, [this]() {
            clickCount++;

            // 循环切换不同的样式
            switch (clickCount % 6)
            {
                case 0:
                    m_dynamicButton->setBorderRadius(5);
                    m_dynamicButton->setText("样式1: 蓝-圆角5");
                    m_dynamicButton->setLightDefaultColor(QColor("#2196F3"));
                    m_dynamicButton->setLightHoverColor(QColor("#42A5F5"));
                    m_dynamicButton->setLightPressColor(QColor("#1976D2"));
                    break;
                case 1:
                    m_dynamicButton->setBorderRadius(15);
                    m_dynamicButton->setText("样式2: 绿-圆角15");
                    m_dynamicButton->setLightDefaultColor(QColor("#4CAF50"));
                    m_dynamicButton->setLightHoverColor(QColor("#66BB6A"));
                    m_dynamicButton->setLightPressColor(QColor("#388E3C"));
                    break;
                case 2:
                    m_dynamicButton->setBorderRadius(25);
                    m_dynamicButton->setText("样式3: 橙-圆角25");
                    m_dynamicButton->setLightDefaultColor(QColor("#FF9800"));
                    m_dynamicButton->setLightHoverColor(QColor("#FFB74D"));
                    m_dynamicButton->setLightPressColor(QColor("#F57C00"));
                    break;
                case 3:
                    m_dynamicButton->setBorderRadius(0);
                    m_dynamicButton->setText("样式4: 紫-直角");
                    m_dynamicButton->setLightDefaultColor(QColor("#9C27B0"));
                    m_dynamicButton->setLightHoverColor(QColor("#BA68C8"));
                    m_dynamicButton->setLightPressColor(QColor("#7B1FA2"));
                    break;
                case 4:
                    m_dynamicButton->setBorderRadius(8);
                    m_dynamicButton->setText("样式5: 红-圆角8");
                    m_dynamicButton->setLightDefaultColor(QColor("#F44336"));
                    m_dynamicButton->setLightHoverColor(QColor("#EF5350"));
                    m_dynamicButton->setLightPressColor(QColor("#D32F2F"));
                    break;
                case 5:
                    m_dynamicButton->setBorderRadius(12);
                    m_dynamicButton->setText("样式6: 青-圆角12");
                    m_dynamicButton->setLightDefaultColor(QColor("#00BCD4"));
                    m_dynamicButton->setLightHoverColor(QColor("#26C6DA"));
                    m_dynamicButton->setLightPressColor(QColor("#0097A7"));
                    break;
            }
        });

        // 启用/禁用复选框连接
        connect(m_enableCheckBox, &QCheckBox::toggled, this, [this](bool checked) {
            m_dynamicButton->setEnabled(checked);
            if (checked)
            {
                m_dynamicButton->setText("按钮已启用 - 点击我改变属性");
            }
            else
            {
                m_dynamicButton->setText("按钮已禁用");
            }
        });

        // 基础按钮点击事件 - 展示点击反馈
        for (int i = 0; i < m_basicButtons.size(); ++i)
        {
            connect(m_basicButtons[i], &ElaPushButton::clicked, this, [i, this]() {
                // 点击时改变文字
                m_basicButtons[i]->setText(QString("按钮被点击了! %1").arg(i + 1));

                // 1秒后恢复原文字
                QTimer::singleShot(1000, this, [i, this]() {
                    switch (i)
                    {
                        case 0:
                            m_basicButtons[i]->setText("默认按钮");
                            break;
                        case 1:
                            m_basicButtons[i]->setText("这是一个带较长文字的按钮");
                            break;
                        case 2:
                            m_basicButtons[i]->setText("不同宽度的按钮");
                            break;
                        case 3:
                            m_basicButtons[i]->setText("不同高度的按钮");
                            break;
                    }
                });
            });
        }

        // 切换按钮连接 - 修正版本
        for (ElaPushButton *toggleBtn : m_toggleButtons)
        {
            connect(toggleBtn, &ElaPushButton::clicked, this, [toggleBtn]() {
                // 获取当前状态
                bool currentState = toggleBtn->property("toggleState").toBool();
                bool newState = !currentState;

                // 更新状态
                toggleBtn->setProperty("toggleState", newState);

                if (newState)
                {
                    // 切换到按下状态
                    QString pressedText = toggleBtn->property("pressedText").toString();
                    toggleBtn->setText(pressedText);
                }
                else
                {
                    // 切换到弹起状态
                    QString normalText = toggleBtn->property("normalText").toString();
                    toggleBtn->setText(normalText);
                }

                // 强制重绘以更新样式
                toggleBtn->update();

                qDebug() << "切换按钮状态:" << toggleBtn->text() << "状态:" << (newState ? "按下" : "弹起");
            });
        }
    }

  private:
    QList<ElaPushButton *> m_basicButtons;
    QList<ElaPushButton *> m_toggleButtons;
    ElaPushButton *m_themeToggleBtn = nullptr;
    ElaPushButton *m_dynamicButton = nullptr;
    ElaPushButton *m_modifyButton = nullptr;
    QCheckBox *m_enableCheckBox = nullptr;
    QLabel *m_themeStatusLabel = nullptr;
};

int main(int argc, char *argv[])
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
    QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);  // 启用高 DPI (界面布局和几何)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
    QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);                                               //  启用自动高 DPI 缩放 (图标和图片)
    QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);  // 使用精确的缩放因子，不进行四舍五入
#else
    // 根据实际屏幕缩放比例更改
    qputenv("QT_SCALE_FACTOR", "1.5");
#endif
#endif

    QApplication app(argc, argv);

    eApp->init();  // 初始化资源、字体等

    ElaPushButtonDemo demo;
    demo.moveToCenter();  // 窗口居中显示
    demo.show();

    return app.exec();
}

#include "ElaPushButtonTest.moc"